<!-- doUserReg.php 用于将用户输入的注册信息添加到数据库。 -->
<?php
  
  require_once('../system/dbConn.php');
  require_once('../system/myFunc.php');
  //连接数据库		
  connect();

  if(!empty($_FILES["pic"]["name"])){
  	$pic = uploadfile('pic',UserPhotoPath,array('jpg','gif','png'));
  }
  else{
  	$pic='';
  }

  $data = array(
		'uname' => trim($_POST['username']),  
		'password' => $_POST['password'],
		'gender' => $_POST['gender'],
		'birthday' => $_POST['birthday'],
		'hobby' => $_POST['hobby'],
		'degree' => $_POST['degree'],
		'intro' => $_POST['intro'],
		'pic'=>$pic
  	);

  //执行SQL语句
	$result = add('users',$data);
  //var_dump($result);

  if(!$result){
  	echo "注册失败！<br/>";
  	echo "<a href='userReg.php'>返回</a>";	  
  }else{	  
 	echo "注册成功！";
 	echo "请使用<a href='./admin/login.html'>管理员登录</a>查看用户信息，";
	echo "或返回<a href='userReg.php'>注册</a>页面！";	  
  }    
  
?>
